#include "Color.h"
#include <pspgu.h>
#include <iostream>
#include <sstream>
using namespace std;
using namespace objdraw;

Color::Color()
{
	r = 0; g = 0; b = 0; a = 255;
}
Color::Color(int _r, int _g, int _b)
{
	r = _r; g = _g; b = _b;
	a = 255;
}
Color::Color(int r, int g, int b, int a)
{
	this->r = r; this->g = g; this->b = b; this->a = a;
}
Color::Color(unsigned int c)
{
	r=c&0xff;
	g=(c>>8)&0xff; 
	b=(c>>16)&0xff;
	a=(c>>24)&0xff;
}
Color Color::operator =(unsigned int c)
{
	r=c&0xff;
	g=(c>>8)&0xff; 
	b=(c>>16)&0xff;
	a=(c>>24)&0xff;
	return Color(r,g,b,a);
}
bool Color::operator ==(Color c)
{
	if(c.gu_c() == gu_c())
		return true;
	return false;
}
bool Color::operator ==(unsigned int c)
{
	if(c == gu_c())
		return true;
	return false;
}
void Color::set(Color c)
{
	r = c.getR(); g = c.getG(); b = c.getB(); a = c.getA();
}
void Color::set(unsigned int c)
{
	r=c&0xff;
	g=(c>>8)&0xff; 
	b=(c>>16)&0xff;
	a=(c>>24)&0xff;
}
void Color::set(int r, int g, int b, int a)
{
	this->r = r; this->g = g; this->b = b; this->a = a;
}
void Color::set(int r, int g, int b)
{
	this->r = r; this->g = g; this->b = b; a = 255;
}
void Color::setR(int r)
{
	this->r = r;
}
void Color::setG(int g)
{
	this->g = g;
}
void Color::setB(int b)
{
	this->b = b;
}
void Color::setA(int a)
{
	this->a = a;
}
int Color::getR()
{
	return r;
}
int Color::getG()
{
	return g;
}
int Color::getB()
{
	return b;
}
int Color::getA()
{
	return a;
}
unsigned int Color::gu_c()
{
	return GU_RGBA(r,g,b,a);
}
string Color::toString()
{
	stringstream rstr("Color: ");
	rstr << "r = " << r
	<< "; g = " << g 
	<< "; b = " << b
	<< "; a = " << a << ";"; 
	return rstr.str();
}

